	.dorg 0x8000

	.const dataPort 0xa
	.const addrPort 0xb
	.const LED_COLS 64

	.reg ledCol     R0
	.reg caddr      R1
	.reg data       R2
	.reg initLedCol R3
	.reg initAddr   R4
	.reg loop       R5
	.reg taddr      R6

start:	LDI initAddr, text
	LDI initLedCol, LED_COLS-1
	
L4:	MOV ledCol, initLedCol
	MOV taddr, initAddr

L2:	LD caddr, [taddr]	; get char
	CPI caddr, 0
	BREQ ende
	SUBI caddr, ' '		; calc font addr
	MULI caddr, 8
	ADDI caddr, font	; addr of char in font

	LDI loop, 8
L1:	CPI ledCol, 0
	BRMI L3
	LD data, [caddr]
	OUT dataPort, data
	OUT addrPort, ledCol
L3:	INC ledCol
	CPI ledCol, LED_COLS
	BREQ ende

	INC caddr
	DEC loop
	BRNE L1

	INC taddr
	JMP L2	

ende:   BRK
	DEC initLedCol
	CPI initLedCol, -8
	BRNE L4
	
	LDI initLedCol,0
	INC initAddr
	
	LD caddr, [initAddr]
	CPI caddr,0
	BRNE L4

	JMP start

	.data text "These are greetings to the whole world!",0

	.data font 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x38,0xdfc,0xdfc,0x38,0x0,0x0,
0x0,0xe,0x1e,0x0,0x0,0x1e,0xe,0x0,
0x220,0xff8,0xff8,0x220,0xff8,0xff8,0x220,0x0,
0x638,0xc7c,0x844,0x3847,0x3847,0xfcc,0x798,0x0,
0xc30,0x630,0x300,0x180,0xc0,0xc60,0xc30,0x0,
0x780,0xfd8,0x87c,0x8e4,0x7bc,0xfd8,0x840,0x0,
0x0,0x10,0x1e,0xe,0x0,0x0,0x0,0x0,
0x0,0x0,0x3f0,0x7f8,0xc0c,0x804,0x0,0x0,
0x0,0x0,0x804,0xc0c,0x7f8,0x3f0,0x0,0x0,
0x80,0x2a0,0x3e0,0x1c0,0x1c0,0x3e0,0x2a0,0x80,
0x0,0x80,0x80,0x3e0,0x3e0,0x80,0x80,0x0,
0x0,0x0,0x1000,0x1e00,0xe00,0x0,0x0,0x0,
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x0,
0x0,0x0,0x0,0xc00,0xc00,0x0,0x0,0x0,
0xc00,0x600,0x300,0x180,0xc0,0x60,0x30,0x0,
0x3f0,0x7f8,0xc0c,0x8c4,0x8c4,0xc0c,0x7f8,0x3f0,
0x0,0x810,0x818,0xffc,0xffc,0x800,0x800,0x0,
0xe08,0xf0c,0x984,0x8c4,0x864,0xc3c,0xc18,0x0,
0x408,0xc0c,0x844,0x844,0x844,0xffc,0x7b8,0x0,
0xc0,0xe0,0xb0,0x898,0xffc,0xffc,0x880,0x0,
0x47c,0xc7c,0x844,0x844,0x844,0xfc4,0x784,0x0,
0x7f0,0xff8,0x84c,0x844,0x844,0xfc0,0x780,0x0,
0xc,0xc,0xf04,0xf84,0xc4,0x7c,0x3c,0x0,
0x7b8,0xffc,0x844,0x844,0x844,0xffc,0x7b8,0x0,
0x38,0x87c,0x844,0x844,0xc44,0x7fc,0x3f8,0x0,
0x0,0x0,0x0,0x630,0x630,0x0,0x0,0x0,
0x0,0x0,0x800,0xe30,0x630,0x0,0x0,0x0,
0x0,0x80,0x1c0,0x360,0x630,0xc18,0x808,0x0,
0x0,0x120,0x120,0x120,0x120,0x120,0x120,0x0,
0x0,0x808,0xc18,0x630,0x360,0x1c0,0x80,0x0,
0x18,0x1c,0x4,0xdc4,0xde4,0x3c,0x18,0x0,
0x7f0,0xff8,0x808,0xbc8,0xbc8,0xbf8,0x1f0,0x0,
0xfe0,0xff0,0x98,0x8c,0x98,0xff0,0xfe0,0x0,
0x804,0xffc,0xffc,0x844,0x844,0xffc,0x7b8,0x0,
0x3f0,0x7f8,0xc0c,0x804,0x804,0xc0c,0x618,0x0,
0x804,0xffc,0xffc,0x804,0xc0c,0x7f8,0x3f0,0x0,
0x804,0xffc,0xffc,0x844,0x8e4,0xc0c,0xe1c,0x0,
0x804,0xffc,0xffc,0x844,0xe4,0xc,0x1c,0x0,
0x3f0,0x7f8,0xc0c,0x884,0x884,0x78c,0xf98,0x0,
0xffc,0xffc,0x40,0x40,0x40,0xffc,0xffc,0x0,
0x0,0x0,0x804,0xffc,0xffc,0x804,0x0,0x0,
0x700,0xf00,0x800,0x804,0xffc,0x7fc,0x4,0x0,
0x804,0xffc,0xffc,0xc0,0x1e0,0xf3c,0xe1c,0x0,
0x804,0xffc,0xffc,0x804,0x800,0xc00,0xe00,0x0,
0xffc,0xffc,0x38,0x70,0x70,0x38,0xffc,0xffc,
0xffc,0xffc,0x38,0x70,0xe0,0xffc,0xffc,0x0,
0x7f8,0xffc,0x804,0x804,0x804,0xffc,0x7f8,0x0,
0x804,0xffc,0xffc,0x844,0x44,0x7c,0x38,0x0,
0x7f8,0xffc,0x804,0xe04,0x3c04,0x3ffc,0x27f8,0x0,
0x804,0xffc,0xffc,0x44,0xc4,0xffc,0xf38,0x0,
0x618,0xe3c,0x864,0x844,0x8c4,0xf9c,0x718,0x0,
0x1c,0xc,0x804,0xffc,0xffc,0x804,0xc,0x1c,
0x7fc,0xffc,0x800,0x800,0x800,0xffc,0x7fc,0x0,
0x1fc,0x3fc,0x600,0xc00,0xc00,0x600,0x3fc,0x1fc,
0x3fc,0xffc,0xe00,0x380,0x380,0xe00,0xffc,0x3fc,
0xc0c,0xe1c,0x330,0x1e0,0x1e0,0x330,0xe1c,0xc0c,
0x1c,0x3c,0x860,0xfc0,0xfc0,0x860,0x3c,0x1c,
0xe1c,0xf0c,0x984,0x8c4,0x864,0x834,0xc1c,0xe0c,
0x0,0x0,0xffc,0xffc,0x804,0x804,0x0,0x0,
0x38,0x70,0xe0,0x1c0,0x380,0x700,0xe00,0x0,
0x0,0x0,0x804,0x804,0xffc,0xffc,0x0,0x0,
0x8,0xc,0x6,0x3,0x6,0xc,0x8,0x0,
0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,
0x0,0x0,0x3,0x7,0x4,0x0,0x0,0x0,
0x700,0xfa0,0x8a0,0x8a0,0x7e0,0xfc0,0x800,0x0,
0x4,0xffc,0xffc,0x820,0x860,0xfc0,0x780,0x0,
0x7c0,0xfe0,0x820,0x820,0x820,0xc60,0x440,0x0,
0x780,0xfc0,0x860,0x824,0x7fc,0xffc,0x800,0x0,
0x7c0,0xfe0,0x8a0,0x8a0,0x8a0,0xce0,0x4c0,0x0,
0x840,0xff8,0xffc,0x844,0xc,0x18,0x0,0x0,
0x27c0,0x6fe0,0x4820,0x4820,0x7fc0,0x3fe0,0x20,0x0,
0x804,0xffc,0xffc,0x40,0x20,0xfe0,0xfc0,0x0,
0x0,0x0,0x820,0xfec,0xfec,0x800,0x0,0x0,
0x0,0x3000,0x7000,0x4000,0x4020,0x7fec,0x3fec,0x0,
0x804,0xffc,0xffc,0x180,0x3c0,0xe60,0xc20,0x0,
0x0,0x0,0x804,0xffc,0xffc,0x800,0x0,0x0,
0xfe0,0xfe0,0x60,0xfc0,0xfc0,0x60,0xfe0,0xfc0,
0x20,0xfe0,0xfc0,0x20,0x20,0xfe0,0xfc0,0x0,
0x7c0,0xfe0,0x820,0x820,0x820,0xfe0,0x7c0,0x0,
0x4020,0x7fe0,0x7fc0,0x4820,0x820,0xfe0,0x7c0,0x0,
0x7c0,0xfe0,0x820,0x4820,0x7fc0,0x7fe0,0x4020,0x0,
0x820,0xfe0,0xfc0,0x860,0x20,0xe0,0xc0,0x0,
0x440,0xce0,0x9a0,0x920,0xb20,0xe60,0x440,0x0,
0x20,0x20,0x7f8,0xffc,0x820,0xc20,0x400,0x0,
0x7e0,0xfe0,0x800,0x800,0x7e0,0xfe0,0x800,0x0,
0x1e0,0x3e0,0x600,0xc00,0xc00,0x600,0x3e0,0x1e0,
0x7e0,0xfe0,0xc00,0x700,0x700,0xc00,0xfe0,0x7e0,
0x820,0xc60,0x6c0,0x380,0x380,0x6c0,0xc60,0x820,
0x47e0,0x4fe0,0x4800,0x4800,0x6800,0x3fe0,0x1fe0,0x0,
0xc60,0xe60,0xb20,0x9a0,0x8e0,0xc60,0xc20,0x0,
0x0,0x40,0x40,0x7f8,0xfbc,0x804,0x804,0x0,
0x0,0x0,0x0,0xfbc,0xfbc,0x0,0x0,0x0,
0x0,0x804,0x804,0xfbc,0x7f8,0x40,0x40,0x0,
0x8,0xc,0x4,0xc,0x8,0xc,0x4,0x0


